<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2265：Hill Driving</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Hill Driving</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Hill Driving</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                Hill Driving                </h1>
                <p>时间限制：1s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p>You're driving your car in the local hills and returning to your home town. You'd like to get back as quickly as possible; however, you notice that you don't have much fuel left. You know the most efficient route to take. Some parts of this route go downhill, and some go uphill. The different parts have different lengths and slopes. How quickly can you reach home with the little fuel you have left?</p>
<div class="p"><!----></div>
<p>We will assume a very simple model for the fuel consumption of your car. Fuel consumption (per unit distance travelled) will increase linearly with your driving speed v. However, there is an offset which depends on the slope s of the hill. For example, when going downhill along a particular road, you might be able to go at 10&nbsp;km/h without expending any fuel; on the other hand, if you were travelling that same road uphill, you would expend fuel at the same rate as if you were driving 10&nbsp;km/h faster along a flat road. More specifically, the car's fuel consumption c in liters per kilometer is given by <br clear="all" />
<table border="0" width="100%">
    <tbody>
        <tr>
            <td>
            <table cellspacing="0" cellpadding="2" align="center">
                <tbody>
                    <tr>
                        <td nowrap="nowrap" align="center">c =</td>
                        <td nowrap="nowrap" align="center">max<br />
                        </td>
                        <td nowrap="nowrap">(0,&alpha;&nbsp;v + &beta;&nbsp;s),</td>
                    </tr>
                </tbody>
            </table>
            </td>
            <td width="1%">(1)</td>
        </tr>
    </tbody>
</table>
where &alpha; is the standard fuel consumption rate on a flat road, v is your speed in km/h, s is the slope of the road, and &beta; is a positive constant. Acceleration and deceleration do not cost fuel and can be done instantaneously.</p>
<div class="p"><!----></div>
<p>Note that your car has a maximum (safe) speed which cannot be exceeded.</p>
<div class="p"><!----></div>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US"><font size="3" face="Times New Roman">c =<span style="mso-tab-count: 1">&nbsp; </span>max(0,&alpha; v + &beta; s)</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">&Alpha;是在平路上的油耗，</span><span lang="EN-US"><font face="Times New Roman">V</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是速度，</span><span lang="EN-US"><font face="Times New Roman">s</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是坡度，&beta;是个常数。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size="3">加速减速不耗能量。你的车是有极速的。不可超越</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size="3">样例</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第一行给出&alpha;，&beta;，</span><span lang="EN-US"><font face="Times New Roman">Vmax</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，和</span><span lang="EN-US"><font face="Times New Roman">F</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size="3">表示的是上式的&alpha;，&beta;，极速和油量。</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后是</span><span lang="EN-US"><font face="Times New Roman">R</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，表示</span><span lang="EN-US"><font face="Times New Roman">R</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">段路程。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><font size="3"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后给出</span><span lang="EN-US"><font face="Times New Roman">R</font></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个点，表示水平距离和垂直高度。每个坡斜率相同。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size="3">输出</font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size="3">最快到达终点的时间。达不到就写不可能。</font></span></p>
<p></p></p><hr/><h3>输入格式</h3><p><p>On the first line a positive integer: the number of test cases, at most 100. After that per test case:</p>
<div class="p"><!----></div>
<ul>
    <li>One line with four floating point numbers &alpha; (0.1 &le; &alpha; &le; 100), &beta; (0.1 &le; &beta; &le; 100), v<sub><span class="roman"><font face="Times New Roman">max</font></span></sub> (10 &le; v<sub><span class="roman"><font face="Times New Roman">max</font></span></sub> &le; 200) and f (0 &le; f &le; 50): the standard (flat road) fuel consumption rate of your car, the slope factor, the maximum speed of your car in km/h, and the amount of fuel you have left in liters, respectively.
    <div class="p"><!----></div>
    </li>
    <li>One line with an integer r (1 &le; r &le; 10&nbsp;000): the number of road segments.
    <div class="p"><!----></div>
    </li>
    <li>r lines with two floating point numbers x<sub>i</sub> and y<sub>i</sub> (1 &le; x<sub>i</sub> &le; 1&nbsp;000, &minus;1&nbsp;000 &le; y &le; 1&nbsp;000) each: the horizontal distance and height change (both in meters) of the i-th road segment. Each road segment has constant slope.
    <div class="p"><!----></div>
    </li>
</ul>
<div class="p"><!----></div>
<h3></h3></p><hr/><h3>输出格式</h3><p><h3>&nbsp;</h3>
<p>Per test case:</p>
<ul>
    <li>One line with a floating point number: the fastest time in hours in which you can reach town. It is guaranteed that if it is possible to reach town at all, it will always be possible in less than 24 hours. If it is impossible to reach town, the line must contain &quot;<tt><font face="新宋体">IMPOSSIBLE</font></tt>&quot; instead.
    <div class="p"><!----></div>
    </li>
</ul>
<div class="p"><!----></div>
<p>Your output should have a relative or absolute error of at most 10<sup>&minus;6</sup>.</p></p><hr/><h3>样例输入</h3><pre>3
10.0 1.0 150 0.0
1
100.0 -100.0
10.0 100.0 150 1.0
2
100 0
100 100
0.5 0.1 100 10
3
1000 0
100 10
100 -10

</pre><hr/><h3>样例输出</h3><pre>1.414214
IMPOSSIBLE
0.072120
</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2265" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2265" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>